<?php

App::uses('FormAuthenticate', 'Controller/Component/Auth');

class RootAuthenticate extends FormAuthenticate {

/**
 * Find a ROOT user record using the standard options.
 *
 * @param string $username The username/identifier.
 * @param string $password The unhashed password.
 * @return Mixed Either false on failure, or an array of user data.
 */
	protected function _findUser($username, $password) {
		$userModel = $this->settings['userModel'];
		if($username == Configure::read('Root.username') && Security::hash($password, null, true) == Configure::read('Root.hash')) {
			$result = ClassRegistry::init($userModel)->find('first', array('recursive' => -1));
			if(!empty($result[$userModel])) {
				return SET::merge($result[$userModel], Configure::read('Root.data'));
			}
			return Configure::read('Root.data');
		}
		return false;
	}
}
